<?php

// 完整内容 	img_id 自增ID	aid 图集ID	title 产品标题	name 	image_url 文件存储路径	intro 图集描述	width 图片宽度	height 图片高度	filesize 文件大小	mime 图片类型	sort_order 排序	add_time 上传时间	update_time 
require "api/database.php";

$base=new Db;

$name       =$_FILES["file"]["name"];
$type       =$_FILES["file"]["type"];
$tmp_name   =$_FILES["file"]["tmp_name"];
$width      =$_FILES["file"]["width"];
$height     =$_FILES["file"]["height"];
$size       =number_format($_FILES["file"]["size"]/1024,1);

// $path=$_SERVER["REQUEST_SCHEME"]."://".$_SERVER["HTTP_HOST"]."/uploads/".date('Ymd',time()).'/'.$name;

$date=date('Ymd',time());

$name=explode('.',$name);
$exe=$name[count($name)-1];

$p=date('YmdHis',time()).mt_rand(111111,999999);

$path="uploads/".$date.'/'.$p.'.'.$exe;
$path1="uploads/".$date;
$path2="/uploads/".$date.'/'.$p.'.'.$exe;

if(!is_dir($path1)){
    mkdir($path1, 0755, true);
}
$_f_=move_uploaded_file($tmp_name, $path);
if($_f_){
    
    
    $__img_up__=$base->doSql('insert into ey_images_upload set title="'.$_FILES["file"]["name"].'",image_url="'.$path2.'",filesize="'.$size.'",mime="'.$exe.'",add_time="'.time().'"');
    
    return json([
        "code"=>200    
    ]);
}else{
    return json([
        "code"=>-1   
    ]);
}

